@isTest
private class PartsLendingApplicationControllerTest {
    static testMethod void testMethod1() {
        
        Product__c p1 = TestUtils.createProduct();
        p1.Brand__c = '迈克';
        p1.Category3__c = '配件';
        p1.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');
        p1.NCCode__c = '1101110000';
        p1.Company__c = '四川省迈克实业有限公司';
        p1.Category0__c = '配件';
        insert p1;


         Price__c pr = new Price__c(
            Product__c = p1.Id,
            MarketPrice__c = 0,
            AreaDealerPrice__c = 1,
            Company__c = '四川省迈克实业有限公司'

        );
        insert pr ;



        PageReference page2 = new PageReference('/apex/PartsLendingApplication');
        System.Test.setCurrentPage(page2);

        PartsLendingApplicationController pla = new PartsLendingApplicationController();
        pla.init();

        Map<String,String> searchMap = new Map<String,String>();
        searchMap.put('NCCode__c','1101110000');


        pla.searchJson = EncodingUtil.urlEncode(JSON.serialize(searchMap), 'UTF-8');

        pla.searchProduct();

        Map<String,Object> saveMap =new Map<String,Object>();

        Map<String,String> baseMap =new Map<String,String>();

        baseMap.put('DocumentTypes__c','库存借出');
        saveMap.put('base', baseMap);
        saveMap.put('datas', JSON.deserializeUntyped(EncodingUtil.urlDecode(pla.dataJson, 'UTF-8')));
        pla.saveJson = EncodingUtil.urlEncode(JSON.serialize(saveMap), 'UTF-8');
        pla.save();


        PartsLendingApplication__c pl = [select Id from PartsLendingApplication__c limit 1];
		System.debug('PartsLendingApplicationControllerTest==>'+pl);

		PageReference page1 = new PageReference('/apex/PartsLendingApplication?id='+pl.Id);
        System.Test.setCurrentPage(page1);

        PartsLendingApplicationController pla1 = new PartsLendingApplicationController();
        pla1.init();

        
    }
}